<?php

/**
 * 会员管理控制器
 * @author:Cloud <190296465@qq.com>
 * @copyright:TcitCMS
 * @since:2014-05-12
 */

namespace Admin\Controller;

use Common\Model\MessageModel;

class MessageController extends AdminController {

    function index() {
        parent::indexInitialize();
        parent::commonIndex();
    }

    function jsonList() {
        parent::indexInitialize();
        $model = new MessageModel();

        $pageNo = I('get.page', '1', 'intval');
        $pagesize = I('get.limit', $this->pagesize, 'intval');
        $pageNum = ($pageNo - 1) * $pagesize;
        $limit = "{$pageNum},{$pagesize}";

        if (I('get.category', '', 'intval'))
            $this->map['category'] = array('EQ', I('get.category'));
        if (I('get.wd', '', 'trim') && $model->_selectFields)
            $this->map[$model->_selectFields] = array('LIKE', '%' . I('get.wd') . '%');

        $count = $model->where($this->map)->count();

        //$pager = new \Common\Org\Pager();
        //$pagerData = $pager->getPagerData($count, $pageNo, $url, 2, $this->pagesize); //参数记录数 当前页数 链接地址 显示样式 每页数量

        $data = $model->where($this->map)->order($this->order)->limit($limit)->select();


        //$data = $model->select();
        $this->ajaxReturn([
            'code' => 0, 'msg' => 'success', 'count' => $count, 'data' => $data
        ]);
    }

    function add() {
        parent::indexInitialize();
        parent::commonAdd();
    }

    function save() {
        parent::commonSave();
    }

    function delete() {
        parent::commonDelete();
    }

}

?>